package com.wanshi.mapper;

import com.wanshi.po.Timu;
import com.wanshi.po.TimuPo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;


public interface TiMapper {

    @Select("select * from timu where id = #{id}")
    Timu findById(String id) ;

//    private int id;
//    private String content;
//    private String url;
//    private String method;
//    private int degree;
//    private int user_id;
//    private Date add_time;
    @Insert("insert into timu (id,content,url,method,degree,user_id,add_time) values(null,#{content},#{url},#{method},#{degree},#{user_id},now())")
    void add(Timu timu);

    @Select(" SELECT *,\n" +
            " (SELECT COUNT(id) FROM record WHERE user_id = #{user_id} AND timu_id = timu.id and result = 1) num\n" +
            " FROM timu")
    List<TimuPo> list(int user_id);
}
